package com.kangyi.utils;

/**
 * @author Blank
 * @version 1.0
 */
public class WebUtil {

    public static String randomCode(int length){
        if(length <= 0){
            throw new RuntimeException("验证码长度不合适");
        }

        StringBuilder stringBuilder = new StringBuilder();

        for (int i = 0; i < length; i++) {
            // 1.生成随机数
            double random = Math.random();
            //2.调整
            int integerRandom = (int) (random * 10);
            //3.凭借
            stringBuilder.append(integerRandom);

        }
        return stringBuilder.toString();
    }
}
